In this article we will discuss about popup window and closing it. To open a window by using window.open(). The window.open() has as 4 optional parameters.
Syntax:
window.open(URL, name, features, replace)
URL: URL is to open a page, if it is not specified a new window will open it should be blanked.
- Name: It is a target attribute or the name of the window.
- _blank URL is loaded in a new window.
- _parent URL is loaded into a parent frame
- _self URL replaces the current page
- _top URL replaces any framesets that may be loaded
Features: The postion of the window where to locate top, left and also has features such as resizable,scrollbars,,heights etc.
Replace: It specifies the URL is new entry or to replaces old entry as new entry. It will work if the url is loaded into the same window. It has two properties true or false.
Example:
<input type="button" value="Open popup" onclick="openPopup()" />
<input type="button" value="Close popup" onclick="closePopup()" />
<script type="text/javascript">
var popup;
function openPopup() {
popup =window.open("http://google.com", "My Window", "height=300,width=300")
}
function closePopup() {
popup.close();
}
</script>
Output:
Post your comments / questions
Recent Article
- FieldError: Cannot resolve keyword 'id' into field in Django project
- How to hide the ID field from the Django admin?
- It is impossible to add a non nullable field without specifying a default. Django error
- ImportError: cannot import name 'url' from 'django.conf.urls' - Django Error
- How to Enable Virtualization in BIOS Security Settings in Intel Processors For Android Studio?
- Dependency 'androidx.activity:activity:1.8.0' requires libraries and applications that depend on it.
- AttributeError: 'NoneType' object has no attribute 'get_text' - Python
- ModuleNotFoundError: No module named 'openpyxl' - Python
Related Article